<template>
	<view>
		<!-- 头部提示 -->
		<navbar :backshow="true" :title="title" :navBarHeight="navBarHeight" :menuRight="menuRight" :menuTop="menuTop"
			:menuHeight="menuHeight"></navbar>
		<!-- tab切换 -->
		<!-- 头部展位 -->
		<view class="main" :style="{ height: mainheight + 'px' }">123</view>
		<view class="tabbox">
			<view class="tabboxitem" :class="{ active: activeTab === 0 }" @click="setActiveTab(0)">
				预约选择
			</view>

			<view class="tabboxitem" :class="{ active: activeTab === 1 }" @click="setActiveTab(1)">
				预约记录
			</view>

			<!-- 下划线标识 -->
			<view class="underline" :style="{ left: underlineLeft }"></view>
		</view>

		<!-- 根据当前选中的Tab显示内容 -->
		<view v-show="activeTab === 0">
			<uni-search-bar class="uni-mt-10" radius="5" placeholder="请输入房间名称" clearButton="auto" cancelButton="none"
				@confirm="search" @input="searchs" v-model="roomName" />
			<!-- 正文 -->
			<view class="roombox">
				<view class="roomitem" v-for="item in roomList" :key="item.roomId"
					:class="room == item.roomId ? 'roomitems' : ''"
					@click="roombookingfn(item.roomId, single, item.roomName, item)">
					{{ item.roomName }}
				</view>
			</view>

			<view class="datamain datamains" v-if="datashow">
				<!-- 显示今日有多少人预约 -->
				<view class="dataylbox" @click="checknb" v-if="qttimer" :key="qttimer.length">
					{{ single }} 今天  有{{ qttimer.length }}人想预约，查看一下时间段
				</view>
				<view class="datedbox">
					<!--  -->
					<!-- <view class="single">
						{{single}}
					</view> -->
					<uni-icons type="back" size="22" @click="dateback"></uni-icons>
					<uni-datetime-picker v-model="single" type="date" class="sing" ref="calendar" :start="start"
						:end="end">
						{{ single }}
					</uni-datetime-picker>
					<uni-icons type="forward" size="22" @click="datenext"></uni-icons>
					<view class="rlbox" @click="open">
						<view class="rlboximage">
							<image src="/static/rl.png" alt="" class="rlboximage" />
						</view>
						<view class="rl">日历</view>
					</view>
				</view>
				<!-- 选择 详细日期 -->
				<view class="datetimebox">
					<view class="datetimeitem" v-for="item in datetime" :key="item.id" @click="activetimeidfn(item)">
						<view class="datetime">
							{{ item.starttime }} - {{ item.endtime }}
						</view>
						<view class="dateacitve" :class="[
                item.disable == false ? 'dateacitvebk' : '',
                item.id == dateactiveid ? 'dateacitveyx' : 'dateacitve',
              ]">
							<!-- 已选择的时候进行提示 -->
							<image src="../../static/yx.png" mode="" class="dateacitveimg"
								v-if="item.id == dateactiveid && item.disable == true"></image>
							<span v-if="item.disable == false">
								{{ item.remark == null ? "未开放" : item.remark }}
							</span>
						</view>
					</view>
				</view>
				<!-- 提示 + 下一步 -->
				<view class="datebottombox">
					<view class="datebsitem">
						<view class="datebsitemla"></view>
						<view class="dateibstemdes">：可选择</view>
					</view>
					<view class="datebsitem">
						<view class="datebsitemlas"></view>
						<view class="dateibstemdes">：已选择</view>
					</view>
					<view class="datebsitem">
						<view class="datebsitemlass"></view>
						<view class="dateibstemdes">：不可选</view>
					</view>
				</view>
				<!-- 下一步 -->
				<view class="nextbox" @click="nextsave">下一步</view>
			</view>
		</view>
		<view v-show="activeTab === 1" class="yyitembox">
			<!-- 预约列表 -->
			<view class="yyitem" v-for="item in roombookings" :key="item.appointmentId" @click="yxroomfn(item)">
				<view class="yybst" :class="{
            yybstyyz: item.auditStatus === 1,
            yybstyjs: item.auditStatus === 2,
            yybstwks: item.auditStatus === 9,
			 yybstwks: item.auditStatus === 11,
          }">
					{{ getStatus(item.startTime, item.endTime, item.auditStatus) }}
				</view>
				<view class="yydeso">
					<view class="yytime">
						<view class="yytimeitem">时间：</view>
						<view class="yytimeitems">
							{{ formatTimeRange(item.startTime, item.endTime) }}
						</view>
					</view>
					<view class="yytime">
						<view class="yytimeitem">主题：</view>
						<view class="yytimeitems">{{ item.appointmentTheme }}</view>
					</view>
					<view class="yytime">
						<view class="yytimeitem">预约人：</view>
						<view class="yytimeitems">{{ item.createUser }}</view>
					</view>
				</view>
				<view class="yydest">
					<view class="yytime">
						<view class="yytimeitem">人数：</view>
						<view class="yytimeitems">{{ item.appointmentNumber }}</view>
					</view>
					<!-- <view class="yytime">
						<view class="yytimeitem">设备：</view>
						<view class="yytimeitems">{{item.startTime}}</view>
					</view> -->
					<view class="yytime">
						<view class="yytimeitem">房间：</view>
						<view class="yytimeitems">{{ item.roomName }}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 提示窗 -->
		<uni-popup ref="alertDialog" type="dialog" class="mg">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="确定" title="提示" content="您的信用分值低于10暂时无法预约!"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="alertDialogs" type="dialog" class="mg">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="确定" title="提示" content="请先选择日期才能进行预约!"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
		<!-- 提示窗示例 -->
		<uni-popup ref="alertDialognb" type="dialog" class="dfys">
			<uni-popup-dialog type="info" :showClose='false' cancelText="1" confirmText="我已知晓" title="他人时间段预约"
				content="">
				<view class="qtsjdyybox">
					<view class="qtsjdyy" v-for="(item, index) in qttimer" :key="item.index">
						{{ item.startTime }} ~ {{ item.endTime }} ({{
              item.remark
            }}人已预约)
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scheduleNumbe: "",
				end: "",
				start: "",
				pageNum: 1,
				pageSize: 20,
				roomPhoto: "",
				yxroom: {
					startTime: "",
					endTime: "",
				},
				roombookings: [],
				roomName: "",
				debounceTimer: null,
				datashow: false,
				roomname: "",
				room: 0,
				underlineLeft: "25%",
				activeTab: 0, // 默认选中第一个Tab
				tabshow: false,
				title: "预约教室",
				navBarHeight: 50, // 导航栏高度
				menuRight: 10, // 胶囊距右方间距（方保持左、右间距一致）
				menuTop: 50, // 胶囊距底部间距（保持底部间距一致）
				menuHeight: 0, // 胶囊高度（自定义内容可与胶囊高度保证一致）
				mainheight: 60,
				roombooking: [],
				dateactiveid: null,
				datetime: [],
				single: "",
				roomList: [],
				items: "",
				qttimer: [],
			};
		},
		onLoad() {
			const that = this;
			// 获取系统信息
			const systemInfo = wx.getSystemInfoSync();
			// 胶囊按钮位置信息
			const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
			// 导航栏高度 = 状态栏高度 + 44
			that.navBarHeight = systemInfo.statusBarHeight + 44;
			that.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
			that.menuTop = menuButtonInfo.top;
			that.menuHeight = menuButtonInfo.height;
			that.mainheight = menuButtonInfo.top + menuButtonInfo.height;
			// 获取一下 最新数据
			this.pageNum = 1;


			this.$myRequest({
				url: "/admin/appointment/room/appointmentDisabled",
				method: "get",
			}).then((res) => {
				this.start = res.data.startDate;
				this.end = res.data.endDate;
				// this.roombookings = res.data.list;
			});
		},
		onReady() {
			this.$myRequest({
				url: "/admin/appointment/room/appointmentTime",
				method: "get",
			}).then((res) => {
				let datas = res.data;
				let idCounter = 1;

				// 使用 map 方法遍历数组，对每个对象进行处理，并构造新的对象
				let transformedData = datas.map((item) => {
					return {
						id: idCounter++,
						starttime: item.startTime,
						endtime: item.endTime,
						disable: true, // 默认设置为 true，您可以根据实际需求调整
					};
				});

				// 更新组件状态或其他操作，将处理后的数据赋值给组件的数据变量

				this.datetime = transformedData
				console.log("获取全局预约时间", this.datetime);
			});
			this.single = this.getNowFormatDate();
		},
		onReachBottom() {
			this.pageNum = this.pageNum + 1;
			this.roombookingfns();
			console.log("触底函数");
		},
		watch: {
			activeTab: {
				handler(i) {
					if (i == 0) {
						this.roomListfn();
					}
					if (i == 1) {
						this.roombookingfns();
					}
				},
				immediate: true,
				deep: true,
			},
			single: {
				handler(i) {
					if (i) {
						this.roombookingfnac(this.room, i, this.roomname, this.scheduleNumbe);
					}
				},
				immediate: true,
				deep: true,
			},
		},
		methods: {
			checknb() {
				this.$myRequest({
					url: "/client/appointment/roomAppointmentSubmit",
					method: "get",
					data: {
						roomId: this.room,
						date: this.single,
					},
				}).then((res) => {
					this.qttimer = res.data;
					if (this.qttimer.length != 0) {
						this.$refs.alertDialognb.open();
					}

					console.log("其他时间预约", res.data);
				});
			},
			getStatus(startTime, endTime, auditStatus) {
				if (!startTime || !endTime) {
					return "未提供开始时间或结束时间";
				}

				// 获取当前时间
				const now = new Date();

				// 替换空格为T，并转换为ISO 8601格式
				const formattedStartTime = startTime.replace(" ", "T");
				const formattedEndTime = endTime.replace(" ", "T");

				// 创建开始时间和结束时间的 Date 对象
				const startDateTime = new Date(formattedStartTime);
				const endDateTime = new Date(formattedEndTime);

				// 根据当前时间和审核状态返回相应状态
				if (auditStatus === 1) {
					if (now < startDateTime) {
						return "未开始";
					} else if (now >= startDateTime && now < endDateTime) {
						return "预约中";
					} else {
						return "已结束";
					}
				} else {
					if (auditStatus === 2) {
						return "不通过";
					}
					if (auditStatus === 9) {
						return "待审核";
					}
					if (auditStatus === 11) {
						return "已过期";
					}
				}
			},
			formatTimeRange(startTime, endTime) {
				if (startTime === "" || endTime === "") {
					return "数据错误";
				}

				// 将字符串转换为 Date 对象
				const startDate = new Date(startTime.replace(/-/g, "/")); // 替换所有的'-'号
				const endDate = new Date(endTime.replace(/-/g, "/"));

				// 格式化日期部分
				const startDateString = this.formatDate(startDate); // 格式化开始日期部分

				// 格式化时间部分
				const startTimeString = this.formatTime(startDate); // 格式化开始时间部分
				const endTimeString = this.formatTime(endDate); // 格式化结束时间部分

				// 格式化成所需的字符串
				const formattedTimeRange = `${startDateString} ${startTimeString}~${endTimeString}`;

				return formattedTimeRange;
			},

			// 辅助函数，格式化日期部分
			formatDate(date) {
				const year = date.getFullYear();
				const month = this.padZero(date.getMonth() + 1); // 月份从0开始，需要加1
				const day = this.padZero(date.getDate());

				// 返回格式化后的日期部分字符串
				return `${year}-${month}-${day}`;
			},

			// 辅助函数，格式化时间部分
			formatTime(date) {
				const hours = this.padZero(date.getHours());
				const minutes = this.padZero(date.getMinutes());

				// 返回格式化后的时间部分字符串
				return `${hours}:${minutes}`;
			},

			// 辅助函数，补零函数，用于确保日期时间部分是两位数
			padZero(num) {
				return num.toString().padStart(2, "0");
			},

			yxroomfn(item) {
				console.log("数据接口");
				// this.bookshow = true
				this.yxroom = item;
				uni.setStorage({
					key: "yxroom",
					data: item,
					success: function() {
						console.log("数据存储成功");
						uni.navigateTo({
							url: "/pages/roomxq/roomxq", // 要跳转的非 tabBar 页面路径，可以带参数
						});
					},
				});

				// console.log("yxroom", this.yxroom);
			},
			roombookingfns() {
				this.$myRequest({
					url: "/client/appointment/roomAppointmentRecord",
					method: "get",
					data: {
						pageNum: this.pageNum,
						pageSize: this.pageSize,
					},
				}).then((res) => {
					console.log("预约列表", res.data);
					// this.roombookings = res.data.list;

					const newListData = [...this.roombookings, ...res.data.list];
					this.roombookings = newListData;
				});
			},
			searchs() {
				const debounceDelay = 300;
				// 每次输入时，先清除之前设置的定时器
				clearTimeout(this.debounceTimer);

				// 设置新的定时器
				this.debounceTimer = setTimeout(() => {
					// 在延迟时间后执行搜索操作
					this.search();
				}, debounceDelay);
			},
			search() {
				this.$myRequest({
					url: "/client/appointment/roomList",
					method: "get",
					data: {
						roomName: this.roomName,
					},
				}).then((res) => {
					console.log("房间列表", res.data);
					this.roomList = res.data;
				});
				console.log("触发搜索");
			},
			// 重制选择列表

			// 选择提交信息
			nextsave() {
				if (this.dateactiveid == 0 || this.dateactiveid == null) {
					this.$refs.alertDialogs.open();
				} else {
					// 跳转前先判断
					uni.navigateTo({
						url: "/pages/roomsave/roomsave", // 要跳转的非 tabBar 页面路径，可以带参数
					});
				}
			},
			// 选择id
			activetimeidfn(item) {
				console.log("选择了日期", this.scheduleNumbe);
				if (item.disable == true) {
					this.dateactiveid = item.id;

					uni.setStorage({
						key: "datetime",
						data: {
							starttime: item.starttime,
							endtime: item.endtime,
							roomId: this.room,
							single: this.single,
							roomname: this.roomname,
							scheduleNumbe: this.scheduleNumbe,
						},
						success: function() {
							console.log("数据存储成功");
						},
					});
				} else {
					this.dateactiveid = 0;
				}
			},
			roombookingfnac(roomId, date, roomName) {
				this.$myRequest({
					url: "/client/appointment/roomAppointmentSubmit",
					method: "get",
					data: {
						roomId: roomId,
						date: date,
					},
				}).then((res) => {
					this.qttimer = res.data;
					// this.$refs.alertDialognb.open();
					// console.log("其他时间预约", res.data);
				});
				//
				this.$myRequest({
					url: "/client/appointmentUser/creditList",
					method: "GET",
				}).then((res) => {
					// console.log('当前信用分', res.data.balance);
					if (res.data.balance < 10) {
						this.$refs.alertDialog.open();
					} else {
						this.room = roomId;
						this.roomname = roomName;
						// this.datashow = true;
						this.rest();
						this.$myRequest({
							url: "/client/appointment/roomAppointmentInfo",
							method: "GET",
							data: {
								roomId: roomId,
								date: date,
							},
						}).then((res) => {
							this.roombooking = res.data;
							// 遍历 data 中的每个对象
							res.data.forEach((item) => {
								// 查找与当前 data1 对象的 startTime 和 endTime 匹配的 datetime 数据项
								let matchingDatetime = this.datetime.find(
									(dt) =>
									dt.starttime === item.startTime && dt.endtime === item
									.endTime
								);
								// 如果找到匹配项，则将其 disable 属性设置为 false
								if (matchingDatetime) {
									matchingDatetime.disable = false;
									matchingDatetime.remark = item.remark;
								}
								// 如果没有找到匹配项，则保持 disable 属性不变（默认为 true）
							});
						});
						// const currentDate = new Date();
						// let datetimes = this.datetime;
						// datetimes.forEach(item => {

						// 	const month = ('0' + (currentDate.getMonth() + 1)).slice(-2); // 月份补零
						// 	const day = ('0' + currentDate.getDate()).slice(-2); // 日期补零
						// 	const startTime = new Date(
						// 		`${currentDate.getFullYear()}-${month}-${day}T${item.starttime}`);
						// 	// console.log('执行了当前时间', currentDate, startTime);

						// 	if (currentDate > startTime) {
						// 		item.disable = false;
						// 		item.remark = '已过期'
						// 		console.log('执行了');
						// 	}
						// });
						// this.datetime = datetimes
						// JSON.parse(item.scheduleTime).forEach((interfaceItem) => {
						// 	// 遍历预设的时间段
						// 	this.datetime.forEach((datetimeItem) => {
						// 		// 将时间字符串转换为分钟数方便比较
						// 		let interfaceStartMinutes = this.timeStringToMinutes(
						// 			interfaceItem.startTime
						// 		);
						// 		let interfaceEndMinutes = this.timeStringToMinutes(
						// 			interfaceItem.endTime
						// 		);
						// 		let datetimeStartMinutes = this.timeStringToMinutes(
						// 			datetimeItem.starttime
						// 		);
						// 		let datetimeEndMinutes = this.timeStringToMinutes(
						// 			datetimeItem.endtime
						// 		);

						// 		// 检查接口返回的时间段是否在预设的时间段内
						// 		if (
						// 			interfaceStartMinutes >= datetimeStartMinutes &&
						// 			interfaceEndMinutes <= datetimeEndMinutes
						// 		) {
						// 			// 设置预设时间段的disable为false
						// 			datetimeItem.disable = false;
						// 		}
						// 	});
						// });
					}
				});

				// console.log('当前房间id', this.room);
				// console.log('点击', roomIds);
			},
			// 查询该房间预约情况
			roombookingfn(roomId, date, roomName, item) {
				// 点击了房间
				//
				this.$myRequest({
					url: "/client/appointment/roomAppointmentSubmit",
					method: "get",
					data: {
						roomId: roomId,
						date: this.single,
					},
				}).then((res) => {

					this.qttimer = res.data;
					// this.$refs.alertDialognb.open();
					console.log("其他时间预约", this.qttimer = res.data);
				});
				this.items = item;
				console.log("点击了房间", item);
				// 先查询一下个人信用分
				this.scheduleNumbe = item.scheduleNumber;
				this.$myRequest({
					url: "/client/appointmentUser/creditList",
					method: "GET",
				}).then((res) => {
					// console.log('当前信用分', res.data.balance);
					if (res.data.balance < 10) {
						this.$refs.alertDialog.open();
					} else {
						this.room = roomId;
						this.roomname = roomName;
						this.datashow = true;
						this.rest();
						this.$myRequest({
							url: "/client/appointment/roomAppointmentInfo",
							method: "GET",
							data: {
								roomId: roomId,
								date: date,
							},
						}).then((res) => {
							this.roombooking = res.data;
							// 遍历 data 中的每个对象
							res.data.forEach((item) => {
								// 查找与当前 data1 对象的 startTime 和 endTime 匹配的 datetime 数据项
								let matchingDatetime = this.datetime.find(
									(dt) =>
									dt.starttime === item.startTime && dt.endtime === item
									.endTime
								);
								// 如果找到匹配项，则将其 disable 属性设置为 false
								if (matchingDatetime) {
									matchingDatetime.disable = false;
									matchingDatetime.remark = item.remark;
								}
								// 如果没有找到匹配项，则保持 disable 属性不变（默认为 true）
							});
						});
						// console.log(' this.datetime', this.datetime)
						// const currentDate = new Date();
						// let datetimes = this.datetime;
						// datetimes.forEach(item => {

						// 	const month = ('0' + (currentDate.getMonth() + 1)).slice(-2); // 月份补零
						// 	const day = ('0' + currentDate.getDate()).slice(-2); // 日期补零
						// 	const startTime = new Date(
						// 		`${currentDate.getFullYear()}-${month}-${day}T${item.starttime}`);
						// 	// console.log('执行了当前时间', currentDate, startTime);

						// 	if (currentDate > startTime) {
						// 		item.disable = false;
						// 		item.remark = '已过期'
						// 		console.log('执行了');
						// 	}
						// });
						// this.datetime = datetimes

					}
				});

				// console.log('当前房间id', this.room);
				// console.log('点击', roomIds);
			},
			timeStringToMinutes(timeString) {
				const [hours, minutes] = timeString.split(":").map(Number);
				return hours * 60 + minutes;
			},
			datenext() {
				let parts = this.single.split("-");
				let year = parseInt(parts[0], 10);
				let month = parseInt(parts[1], 10);
				let day = parseInt(parts[2], 10);

				// 减少一天
				let date = new Date(year, month - 1, day); // month - 1 是因为 JavaScript 中月份从 0 开始
				date.setDate(date.getDate() + 1);

				// 格式化为 'yyyy-mm-dd' 形式的字符串
				year = date.getFullYear();
				month = ("0" + (date.getMonth() + 1)).slice(-2);
				day = ("0" + date.getDate()).slice(-2);
				this.single = `${year}-${month}-${day}`;
			},
			dateback() {
				let parts = this.single.split("-");
				let year = parseInt(parts[0], 10);
				let month = parseInt(parts[1], 10);
				let day = parseInt(parts[2], 10);

				// 减少一天
				let date = new Date(year, month - 1, day); // month - 1 是因为 JavaScript 中月份从 0 开始
				date.setDate(date.getDate() - 1);

				// 格式化为 'yyyy-mm-dd' 形式的字符串
				year = date.getFullYear();
				month = ("0" + (date.getMonth() + 1)).slice(-2);
				day = ("0" + date.getDate()).slice(-2);
				this.single = `${year}-${month}-${day}`;
			},
			open() {
				this.$refs.calendar.show();
			},

			// focus
			focus() {
				console.log("失去焦点");
			},
			//获取当前日期函数
			getNowFormatDate() {
				let date = new Date(),
					year = date.getFullYear(), //获取完整的年份(4位)
					month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
					strDate = date.getDate(); // 获取当前日(1-31)
				if (month < 10) month = `0${month}`; // 如果月份是个位数，在前面补0
				if (strDate < 10) strDate = `0${strDate}`; // 如果日是个位数，在前面补0

				return `${year}-${month}-${strDate}`;
			},
			dated() {
				console.log("更新single", this.single);
			},
			roomListfn() {
				this.$myRequest({
					url: "/client/appointment/roomList",
					method: "get",
					data: {
						roomName: this.roomName,
					},
				}).then((res) => {
					console.log("房间列表", res.data);
					this.roomList = res.data;
				});
			},

			setActiveTab(index) {
				this.activeTab = index;
				this.updateUnderlinePosition();
			},
			updateUnderlinePosition() {
				// 根据activeTab计算下划线的位置
				if (this.activeTab == 0) {
					this.underlineLeft = "25%";
				}
				if (this.activeTab == 1) {
					this.underlineLeft = "75%";
				}
			},
			rest() {
				console.log('查询当前房间单独设置时间情况', this.items.scheduleTime);

				let datas = JSON.parse(this.items.scheduleTime);
				let idCounter = 1;

				// 使用 map 方法遍历数组，对每个对象进行处理，并构造新的对象
				let transformedData = datas.map((item) => {
					return {
						id: idCounter++,
						starttime: item.startTime,
						endtime: item.endTime,
						disable: true,
						disabled: item.disabled
						// 默认设置为 true，您可以根据实际需求调整
					};
				});
				console.log('更新后的初始时间', transformedData);
				// 更新组件状态或其他操作，将处理后的数据赋值给组件的数据变量
				this.datetime = transformedData;
				const currentDate = new Date();
				const currentDates = new Date(this.single);
				console.log('当前日期', );
				let datetimes = this.datetime;
				datetimes.forEach(item => {
					// console.log('thissing', );

					const month = ('0' + (currentDates.getMonth() + 1)).slice(-2); // 月份补零
					const day = ('0' + currentDates.getDate()).slice(-2); // 日期补零
					const startTime = new Date(
						`${currentDates.getFullYear()}-${month}-${day}T${item.starttime}`);
					// console.log('执行了当前时间', currentDate, startTime);
					if (item.disabled == 9) {
						item.disable = false;
						item.remark = '未开放'
					} else {
						if (currentDate > startTime) {
							item.disable = false;
							item.remark = '已过期'
							console.log('执行了');
						}
					}

				});
				this.datetime = datetimes
				console.log("rest全局时间获取", this.datetime);

			},
			// rest() {
			// 	console.log('查询当前房间单独设置时间情况', this.items.scheduleTime);
			// 	this.$myRequest({
			// 		url: "/admin/appointment/room/appointmentTime",
			// 		method: "get",
			// 	}).then((res) => {
			// 		let datas = res.data;
			// 		let idCounter = 1;

			// 		// 使用 map 方法遍历数组，对每个对象进行处理，并构造新的对象
			// 		let transformedData = datas.map((item) => {
			// 			return {
			// 				id: idCounter++,
			// 				starttime: item.startTime,
			// 				endtime: item.endTime,
			// 				disable: true, // 默认设置为 true，您可以根据实际需求调整
			// 			};
			// 		});

			// 		// 更新组件状态或其他操作，将处理后的数据赋值给组件的数据变量
			// 		this.datetime = transformedData;
			// 		const currentDate = new Date();
			// 		const currentDates = new Date(this.single);
			// 		console.log('当前日期', );
			// 		let datetimes = this.datetime;
			// 		datetimes.forEach(item => {
			// 			// console.log('thissing', );

			// 			const month = ('0' + (currentDates.getMonth() + 1)).slice(-2); // 月份补零
			// 			const day = ('0' + currentDates.getDate()).slice(-2); // 日期补零
			// 			const startTime = new Date(
			// 				`${currentDates.getFullYear()}-${month}-${day}T${item.starttime}`);
			// 			// console.log('执行了当前时间', currentDate, startTime);

			// 			if (currentDate > startTime) {
			// 				item.disable = false;
			// 				item.remark = '已过期'
			// 				console.log('执行了');
			// 			}
			// 		});
			// 		this.datetime = datetimes
			// 		console.log("rest全局时间获取", this.datetime);
			// 	});
			// },
		},
	};
</script>

<style></style>